package com.ibeeking.found.msg.rest.controller.v1;

import com.ibeeking.found.msg.rest.service.ISmsConfigSignService;
import com.ibeeking.found.msg.service.common.param.SmsConfigSignParam;
import com.ibeeking.found.msg.service.common.query.SmsConfigSignQuery;
import com.ibeeking.found.msg.service.common.vo.SmsConfigSignVO;
import com.ibeeking.nematos.constants.enums.LogSourceEnum;
import com.ibeeking.nematos.constants.enums.OperateLogTypeEnum;
import com.ibeeking.nematos.log.annotation.Log;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName SmsConfigController控制器
 * @Description
 * @Author ibeeking
 * @Date 2020-12-09 10:54
 **/
@RestController
@RequestMapping("/msg/smsConfigSign/v1")
public class SmsConfigSignController {

    @Resource
    private ISmsConfigSignService smsConfigServiceSignImpl;

    @Log(logSource = LogSourceEnum.TENANT_LOG, logType = OperateLogTypeEnum.QUERY, describe = "查询短信签名列表")
    @PostMapping(value = "/listSmsConfigSign")
    public List<SmsConfigSignVO> listSmsConfigSign(@RequestBody SmsConfigSignQuery query) {
        return smsConfigServiceSignImpl.list(query);
    }

    @Log(logSource = LogSourceEnum.TENANT_LOG, logType = OperateLogTypeEnum.QUERY, describe = "查询所有短信签名列表")
    @PostMapping(value = "/listAllSmsConfigSign")
    public List<SmsConfigSignVO> listAllSmsConfigSign() {
        return smsConfigServiceSignImpl.listAll();
    }

    @Log(logSource = LogSourceEnum.TENANT_LOG, logType = OperateLogTypeEnum.SAVE, describe = "添加短信签名")
    @PostMapping(value = "/saveSmsConfigSign")
    public Boolean saveSmsConfigSign(@RequestBody @Validated SmsConfigSignParam param) {
        return smsConfigServiceSignImpl.add(param);
    }

    @Log(logSource = LogSourceEnum.TENANT_LOG, logType = OperateLogTypeEnum.MODIFY, describe = "添加短信签名")
    @PostMapping(value = "/modifySmsConfigSign")
    public Boolean modifySmsConfigSign(@RequestBody @Validated SmsConfigSignParam param) {
        return smsConfigServiceSignImpl.modify(param);
    }

    @Log(logSource = LogSourceEnum.TENANT_LOG, logType = OperateLogTypeEnum.QUERY, describe = "查询短信签名详情")
    @PostMapping(value = "/viewSmsConfigSign/{id}")
    public SmsConfigSignVO viewSmsConfigSign(@PathVariable("id") Long id) {
        return smsConfigServiceSignImpl.view(id);
    }

    @Log(logSource = LogSourceEnum.TENANT_LOG, logType = OperateLogTypeEnum.MODIFY, describe = "更新短信签名状态")
    @PostMapping(value = "/changeDefaultStatus/{id}/{status}")
    public Boolean changeDefaultStatus(@PathVariable("id") Long id, @PathVariable("status") Integer status) {
        return smsConfigServiceSignImpl.changeDefaultStatus(id, status);
    }

    @Log(logSource = LogSourceEnum.TENANT_LOG, logType = OperateLogTypeEnum.MODIFY, describe = "更新短信签名状态")
    @PostMapping(value = "/changePusblishStatus/{id}/{status}")
    public Boolean changePusblishStatus(@PathVariable("id") Long id, @PathVariable("status") Integer status) {
        return smsConfigServiceSignImpl.changePusblishStatus(id, status);
    }

    @Log(logSource = LogSourceEnum.TENANT_LOG, logType = OperateLogTypeEnum.DEL, describe = "删除短信签名")
    @PostMapping(value = "/delSmsConfigSign/{id}")
    public Boolean delSmsConfigSign(@PathVariable("id") Long id) {
        return smsConfigServiceSignImpl.del(id);
    }
}
